#include "stdafx.h"
#include "ckArgument.h"
#include "ckValue.h"

namespace ck
{
	Argument::Argument()
	{
		m_pValue = NULL;
	}

	Argument::~Argument()
	{
		if (m_pValue != NULL)
		{
			m_pValue->Release();
			m_pValue = NULL;
		}
	}

	const char*	Argument::GetKey()
	{
		return m_strKey.c_str();
	}

	const char* Argument::GetAlias()
	{
		return m_strAlias.c_str();
	}

	Value* Argument::GetValue()
	{
		return m_pValue;
	}

	RESULTCODE Argument::Set(const char* szKey, const char* szAlias, Value* pValue)
	{
		if (szKey == NULL)
		{
			return RC_FAILURE;
		}
		m_strKey = szKey;

		m_strAlias = (szAlias == NULL) ? "" : szAlias;

		if (m_pValue != NULL)
		{
			m_pValue->Release();
			m_pValue = NULL;
		}
		m_pValue = pValue;

		return RC_SUCCESS;
	}
}


